<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layui=""
      th:replace="pages/common/main :: layout(~{::title}, ~{::section}, ~{}, ~{::script})">
    <head>
        <title>字典</title>
    </head>
    <body>
        <section>

            <div class="layui-fluid">

                <script type="text/html" id="toolBar">
                    <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="create"
                       layui:auth="/unicomjs/goods-type/save">
                        <i class="layui-icon layui-icon-file-b">新建分类</i>
                    </a>
                    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deleteBatch"
                       layui:auth="/unicomjs/goods-type/batch-delete">
                        <i class="layui-icon layui-icon-delete">批量删除</i>
                    </a>
                </script>

                <script type="text/html" id="tool">
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"
                       layui:auth="/unicomjs/goods-type/delete">删除</a>
                </script>

                <div class="layui-card">
                    <div class="layui-card-body">
                        <table id="goods-type-table" lay-filter="goods-type-table-filter"></table>
                    </div>
                </div>

            </div>

        </section>

        <script th:inline="javascript">

            layui.use(["grid", "form", "ax", "jquery", "admin"], function () {
                var grid = layui.grid,
                    form = layui.form,
                    $ax = layui.ax,
                    admin = layui.admin,
                    $ = layui.jquery;

                var dicttype = {}
                    , col = [
                    {type: 'checkbox'},
                    {field: 'id', align: "center", title: 'ID'},
                    {field: 'name', align: "center", edit: true, title: '名称'},
                    {align: 'center', toolbar: '#tool', title: '操作', width: 220}
                ];

                dicttype.table = {
                    height: "full-98",
                    cols: [col],
                    // url: "",
                    data: /*[[${data}]]*/[]
                };

                dicttype.eventOptions = {
                    create: {
                        url: "/unicomjs/goods-type/form"
                    },
                    deleteBatch: {
                        url: "/unicomjs/goods-type/batch-delete",
                        after: function (obj, param, that) {
                            admin.refresh()
                        }
                    },
                    delete: {
                        url: "/unicomjs/goods-type/delete",
                        after: function (obj, param, that) {
                            admin.refresh()
                        }
                    }
                }


                var options = {
                        tableId: "goods-type-table",
                        tableFilter: "goods-type-table-filter",
                        table: dicttype.table,
                        eventOptions: dicttype.eventOptions
                    },
                    events = {};

                grid.render(options, events);

            });

        </script>


    </body>
</html>
